package com.vue.mapper;


import com.github.pagehelper.Page;
import com.vue.annotation.AutoFill;
import com.vue.dto.StudentPageQueryDTO;
import com.vue.entity.Student;
import com.vue.enumeration.OperationType;
import com.vue.vo.UserInfoVO;
import org.apache.ibatis.annotations.*;


@Mapper
public interface StudentMapper {

    /**
     * 动态获取学生数据
     * @param userInfoVO
     * @return
     */
    Student getStudent(UserInfoVO userInfoVO);

    /**
     * 学生分页查询
     * @param studentPageQueryDTO
     * @return
     */
    Page<Student> studentPageQuery(StudentPageQueryDTO studentPageQueryDTO);

    /**
     * 根据id删除学生
     * @param id
     */
    @Delete("delete from student where id=#{id}")
    void deleteById(Long id);

    /**
     * 添加学生
     * @param student
     */
    @AutoFill(OperationType.INSERT)
    @Insert("insert into student (username,name,gender,major,course_id,create_time,update_time) " +
            "values (#{username},#{name} ,#{gender},#{major},#{courseId},#{createTime},#{updateTime})")
    void insert(Student student);

    /**
     * 修改学生
     * @param student
     */
    @AutoFill(OperationType.UPDATE)
    void update(Student student);
}
